#pragma once

#include "typedefs.h"
#include "controls.h"
#include "bspline_opt.h"

namespace outline {

struct fast_bspline_adjust_params : bspline_opt_params {
	uint search_half_window;
public:
	fast_bspline_adjust_params() { }
	fast_bspline_adjust_params(
		uint iterations_, 
		float sampling_max_distance_, 
		fit_mode fit_,
		transform_type global_transform_,
		bool antiloop_,
		uint search_half_window_
	) :
		bspline_opt_params(iterations_, sampling_max_distance_, fit_, global_transform_, antiloop_),
		search_half_window(search_half_window_)
		{ }
};

template <typename T, typename R>
R fast_bspline_adjust(
	std::vector< point<T> > const & nodes, ///< input nodes of polyline
	fast_bspline_adjust_params const & params,
	//in & out
	controls<R> & ctrls, ///< size = 3*(the number of pieces) + 1
	//in
	std::vector<junc_type> const & junc, ///< required type of each junction in poly-Bezier
	//out
	std::vector< point<R> > * poles = 0, 
	std::vector< point<R> > * samples = 0,
	//attraction: each node and control point may have attractor to which it's pulled with relative force 'traction'
	std::vector< point<R> > const * attractors = 0,
	std::vector<R> const * tractions = 0, //0 <= traction <= 1; 0 is absence of traction, 1 - control is fixed in attractor
	std::vector<int> const * fixed_dir_tangents = 0 ///< each component here is a bitmap and it describes a node (junction)
);

} //namespace outline

